import 'package:flutter/material.dart';

class SwitchDemo extends StatefulWidget {
  SwitchDemo({Key key}) : super(key: key);

  _SwitchDemoState createState() => _SwitchDemoState();
}

class _SwitchDemoState extends State<SwitchDemo> {
  bool _switchitemA = true;
  bool _switchitemA1 = false;
  void _handradiochanged(bool value) {
    setState(() {
      _switchitemA = value;
    });
  }

  void _handradiochanged1(bool value) {
    setState(() {
      _switchitemA1 = value;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SwitchDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('_switchitemA == $_switchitemA'),
            Text('_switchitemA1 == $_switchitemA1'),
            SwitchListTile(
              value: _switchitemA,
              onChanged: _handradiochanged,
              title: Text('title'),
              subtitle: Text('subtitles'),
              selected: _switchitemA,
              secondary:
                  Icon(_switchitemA ? Icons.visibility : Icons.visibility_off),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Switch(
                  value: _switchitemA1,
                  onChanged: _handradiochanged1,
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
